/* Copyright Thanh-Trung Pham, JAIST, 2013 */

package jp.ac.jaist.input;

import jp.ac.jaist.MVPStructureType;

/**
 *
 * @author Thanh-Trung Pham
 */
public class RMPIAgreementOfErrorsVectorWrapper {
    private double[] m_dAgreementOfErrorsVector;
    private int m_iMinMajoritySize;
    private int m_iNumberOfMVPParts;

    /**
     * The constructor.
     * @param agreementOfErrorsVector the agreement of errors vector from the input model.
     * @param minMajoritySize the minimum majority size from the input model.
     * @param numberOfMVPParts the number of MVPParts from the input model.
     */
    public RMPIAgreementOfErrorsVectorWrapper(MVPStructureType.AgreementOfErrorsVector agreementOfErrorsVector, int minMajoritySize, int numberOfMVPParts){
        m_iMinMajoritySize = minMajoritySize;
        m_iNumberOfMVPParts = numberOfMVPParts;

        m_dAgreementOfErrorsVector = new double[numberOfMVPParts-minMajoritySize+1];
        for(int i=0;i <m_dAgreementOfErrorsVector.length; i++){
            m_dAgreementOfErrorsVector[0]=0;
        }

        MVPStructureType.AgreementOfErrorsVector.ForNumberOfErrors[] oVectorOfForNumberOfErrors = agreementOfErrorsVector.getForNumberOfErrorsArray();
        for(MVPStructureType.AgreementOfErrorsVector.ForNumberOfErrors oForNumberOfErrors: oVectorOfForNumberOfErrors){
            int iForNumberOfErrors = oForNumberOfErrors.getForNumberOfErrors();

            double dProbability = oForNumberOfErrors.getProbability();
            m_dAgreementOfErrorsVector[iForNumberOfErrors-m_iMinMajoritySize] = dProbability;
        }


    }

    /**
     * Get the agreement of errors for the given of number of errors.
     * @param forNumberOfErrors the given of number of errors.
     * @return the agreement of errors for the given of number of errors.
     */
    public double getAgreementOfErrors(int forNumberOfErrors){
        return m_dAgreementOfErrorsVector[forNumberOfErrors-m_iMinMajoritySize];
    }

}
